home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Looking for date & distance routines
- Date: Sat, 13 Apr 96 14:01:10 GMT
- Organization: none
- Message-ID: <829404070snz@genesis.demon.co.uk>
- References: <4kn6e7$ba9@ux.accesscom.net> <4kns53$ge2@nntp.Stanford.EDU>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4kns53$ge2@nntp.Stanford.EDU>
- karish@pangea.Stanford.EDU "Chuck Karish" writes:
-
- >In article <4kn6e7$ba9@ux.accesscom.net>, Wisdom <wisdom@wisdom.com> wrote:
- >>
- >>I'm in search of two sets of routines:
- >>
- >> 1. Code to calculate the amount of days between two time_t-type
- >>date variables, and a routine to return a date x days from a specified
- >>time_t structure.
- >
- >On what type of system? If your C library has mktime(), it will
- >convert data in a struct tm into a time_t, at which point you can
- >subtract and divide by 84600.
-
- You can't subtract two time_t values directly to give anything meaningful
- since the representation of time_t is not specified. You use difftime()
- to get the difference between two time_t values in seconds. You can then
- divide that by 86400 (not 84600) if that makes sense. Remember that there
- aren't always 24 hours in a day (changes to and from daylight saving time)
- and 23:59 and 2 minutes later are in different days.
-
- The problem needs to be specified more precisely to determine an
- appropriate solution.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-